/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package library.control;

import java.util.ArrayList;
import java.util.List;
import library.control.db.DBControl;
import library.control.file.FileControl;
import library.control.st.StaticControl;

/**
 *
 * @author MonStar
 */
public class ControlProvider {

    private List<IControlBook> listControlBook;
    private static ControlProvider control;

    public static ControlProvider getControl() {
        if (control == null) {
            control = new ControlProvider();
        }
        return control;
    }

    private ControlProvider() {
        listControlBook = new ArrayList<>();
        StorageType[] values = StorageType.values();
        for (StorageType storageType : values) {
            listControlBook.add(storageType.getProvider());
        }
    }

    public List<IControlBook> getListControlBook() {
        return listControlBook;
    }

    public static enum StorageType {

        DB(new DBControl()),
        FILE(new FileControl()),
        STATIC(new StaticControl());
        private IControlBook provider;

        StorageType(IControlBook provider) {
            this.provider = provider;
        }

        public IControlBook getProvider() {
            return this.provider;
        }
    }
}